home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / oasis / oasisegs.lha / egs / lips.lisp < prev    next >
Lisp/Scheme  |  1992-04-23  |  649b  |  21 lines

  1. (proclaim '(function run  (fixnum) nil))
  2. (proclaim '(function rev  () list))
  3. (proclaim '(function nrev (list) list))
  4. (proclaim '(function app  (list list) list))
  5.  
  6. (defun run (n)
  7.        (declare (type fixnum n))
  8.        (when (> n 0) (rev) (run (- n 1))) )
  9.  
  10. (defun rev () (nrev '(1 2 3 4 5 6 7 8 9 0
  11.                       1 2 3 4 5 6 7 8 9 0
  12.                       1 2 3 4 5 6 7 8 9 0) ))
  13.  
  14. (defun nrev (xs)
  15.        (declare (type list xs))
  16.        (if (null xs) nil (app (nrev (cdr xs)) (cons (car xs) nil))) )
  17.  
  18. (defun app (xs ys)
  19.        (declare (type list xs)
  20.                 (type list ys))
  21.        (if (null xs) ys (cons (car xs) (app (cdr xs) ys))) )